package com.ruoyi.system.dao.impl;

import cn.xbatis.core.mvc.impl.DaoImpl;
import cn.xbatis.core.sql.executor.chain.QueryChain;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.system.dao.SysDictDataDao;
import com.ruoyi.system.domain.vo.SysDictDataVo;
import com.ruoyi.system.mapper.SysDictDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 字典数据表 Dao 实现类
 * </p>
 *
 * @author xxx
 * @since 2025-02-23
 */
@Repository
public class SysDictDataDaoImpl extends DaoImpl<SysDictData, Long> implements SysDictDataDao {

    @Autowired
    public SysDictDataDaoImpl(SysDictDataMapper sysDictDataMapper) {
        super(sysDictDataMapper);
    }

    @Override
    protected SysDictDataMapper getMapper() {
        return (SysDictDataMapper) this.mapper;
    }

    @Override
    public List<SysDictDataVo> selectDictDataByType(String dictType) {
        return QueryChain.of(getMapper())
            .eq(SysDictData::getStatus, UserConstants.DICT_NORMAL)
            .eq(SysDictData::getDictType, dictType)
            .returnType(SysDictDataVo.class)
            .orderBy(SysDictData::getDictSort).list();
    }
}
